package flyshoes.controller;


import flyshoes.mybatis.entity.Order;
import flyshoes.mybatis.entity.Result;
import flyshoes.service.MyOrderServiceImpl;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.security.PublicKey;
import java.util.List;

@RestController
@RequiredArgsConstructor
@RequestMapping("/order")
public class MyOrderServiceController {
    private final MyOrderServiceImpl orderService;
    @GetMapping("/allOrder")    //查找所有的订单
    public Result allOrder(){
        return orderService.allOrder();
    }
    @GetMapping("/notPayOrder")    //查找未支付的订单
    public Result notPayOrder(){     //查找待支付的订单
        return orderService.notPayOrder();
    }
    @GetMapping("/alreadyPayOrder")   //查找已支付的订单
    public Result alreadyPayOrder(){      //查找已支付的订单
        return orderService.alreadyPayOrder();
    }
    @PostMapping("/createOrder")  //生成单个或多个商品的订单
    public Result createOrder(@RequestBody List<Order> order) {
        return orderService.createdOrder(order);
    }
    @DeleteMapping("/{productId}/deleteOrder")       //取消订单，删除订单
    public Result deleteOrder(@PathVariable Integer productId){
        return orderService.deleteOrder(productId);
    }
    @GetMapping("/refund")          //退款
    public Result refund(){
        return Result.fail("暂不支持退款");
    }
}
